import java.util.ArrayList;
import java.util.Stack;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2024/8/23-上午9:22
 * Since  :   1.0
 * Version:   1.0
 */
public class MyStack {
    public int maxSize;
    public int top = -1;
    public Object array[];

    public MyStack(int maxSize) {
        this.maxSize = maxSize;
        array=new Object[maxSize];
    }


    public boolean isFull() {
        return top == maxSize - 1;
    }

    public boolean isEmpty() {
        return top == -1;
    }

    public void push(Object data) {
        if (isFull()) {
            System.out.println("stack is full");
            return;
        }
        top++;
        array[top] = data;
        return;

    }

    public Object pop() {
        if (isEmpty()) {
            System.out.println("stack is empty");

        }
        Object result = array[top];
        top--;
        return result;

    }

    public void showStack() {
        if (isEmpty()) {
            System.out.println("stack is empty");
        }

        for (Object data : array) {
            System.out.println(array[top]);
            top--;
        }

    }

    public Object peek() {
        return array[top];

    }

    public static void main(String[] args) {

    }

    public Boolean isHuiWen(String s) {
        Stack<Object> stack = new Stack<>();
        for (char c : s.toCharArray()) {
            stack.push(c);
        }
        StringBuffer stringBuffer = new StringBuffer();
        if (!stack.isEmpty()) {
            stringBuffer.append(stack.pop());

        }
        if (stringBuffer.toString().equals(s)) {
            return true;
        }
        return false;

    }

    public Boolean isHuiWen2(String s) {
     return  new StringBuffer(s).reverse().equals(s);
    }


}
